package thread.threaddemo;

/**
 * @Author: wenjingyuan
 * @Date: 2022/11/02/20:52
 * @Description:线程的随机执行
 */
public class ThreadDemo121 {
    public static void main(String[] args) {
        //首先我们先得创一个分组
        ThreadGroup group=new ThreadGroup("group-Thread");
        //其次我们可以给分组里边的线程创建一个任务
        Runnable runnable=new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName()+"在执行");
            }
        };

        Thread t1=new Thread(group,runnable);
        Thread t2=new Thread(group,runnable);
        Thread t3=new Thread(group,runnable);
        Thread t4=new Thread(group,runnable);
        Thread t5=new Thread(group,runnable);
        Thread t6=new Thread(group,runnable);
        Thread t7=new Thread(group,runnable);
        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
        t7.start();
        System.out.println(Thread.currentThread().getName()+"主线程执行");

    }
}
